//package com.aivin.txSms;
//
//import com.alibaba.fastjson.JSONObject;
//
//import java.io.BufferedReader;
//import java.io.InputStreamReader;
//import java.io.OutputStreamWriter;
//import java.net.HttpURLConnection;
//import java.net.URL;
//import java.util.Random;
//
///**
// * Created by Administrator on 2016/10/21.
// */
//public class Smscallback {
//    Random random = new Random();
//    int sdkappid;
//    String appkey;
//    public String url = "https://yun.tim.qq.com/v3/sms/smscallback";
//
//
//    public Smscallback(int sdkappid, String appkey) {
//        this.sdkappid = sdkappid;
//        this.appkey = appkey;
//    }
//    public void smscallback(String nationCode, String mobile, String content_code, long time) {
////        String wholeUrl = url;
//        long rnd = random.nextInt(999999)%(999999-100000+1)+100000;
//        String wholeUrl = String.format("%s?sdkappid=%d&random=%d", url, sdkappid, rnd);
//        try {
//            URL object = new URL(wholeUrl);
//            HttpURLConnection con = (HttpURLConnection) object.openConnection();
//            con.setDoOutput(true);
//            con.setDoInput(true);
//            con.setRequestProperty("Content-Type", "application/json");
//            con.setRequestProperty("Accept", "application/json");
//            con.setRequestMethod("POST");
//
//
//            JSONObject data = new JSONObject();
////            JSONObject tel = new JSONObject();
//
//            data.put("nationcode", nationCode);
//            data.put("mobile", mobile);
//            data.put("content_code", content_code);
//            data.put("time", time); //unix时间戳
//
//            OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream(), "utf-8");
//            wr.write(data.toString());
//            wr.flush();
//
//
//            System.out.println("请求验证 验证码的请求包体内容是:\n" + data.toString());
//            // 显示 POST 请求返回的内容
//            StringBuilder sb = new StringBuilder();
//            int HttpResult2 = con.getResponseCode();
//            if (HttpResult2 == HttpURLConnection.HTTP_OK) {
//                BufferedReader br2 = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"));
//                String line = null;
//                while ((line = br2.readLine()) != null) {
//                    sb.append(line + "\n");
//                }
//                br2.close();
//                System.out.println("返回信息>>" + sb.toString());
//            } else {
//                System.out.println("网络异常>>>" + con.getResponseMessage());
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//}
